<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <meta charset="UTF-8">
    <script src="/home/ubuntu/data/web/app/static/js/function_all.js"></script>
</head>
<style>
    .tableShow{
 white-space: nowrap;
}
</style>
<body>
<!--展示结构-->
<div id="head">
</div>
<div id="container">
</div>

<script src="/home/ubuntu/data/web/app/static/js/function_all.js"></script>
<script type="text/javascript">

    //获取当前窗口的url--得到排序好的index
    var test = window.location.href;
    var temp = test.split('=')[1];
    var indexList = temp.split(',');
    //将index的格式变成数字形式
    for(var x=0;x<indexList.length;x++){
        indexList[x]=Number(indexList[x]);
    }
    //
    // //将数据显示出来--动态生成开头
    // var original_data = jsjx_original();
    // var html_head="<h4>患者信息:[年龄int] [体重kg] [身高cm]"+ original_data[0]["patient_information"];
    // html_head+="</h4><h4>患者自述:" +original_data[1]["condition_report"];
    // html_head+="</h4><h4>舌照:"+"<a href='' onclick='original_fun()'>图片显示</a>";
    // html_head+="</h4><h4>舌照特征:"+ original_data[4]["tongue_vector"]+"</h4>";
    // $('#head').html(html_head);
    //将数据显示出来--动态生成开头--原始患者
    // var original_data = jsjx_original();//获取原始患者数据

    var html_head="<h4>患者信息:[年龄int] [体重kg] [身高cm]"+ '{{user_info}}';
    html_head+="</h4><h4>患者自述:" +'{{report}}';
    html_head+="</h4><h4>舌照:"+"<a href='' onclick='original_fun({{tongue_file|safe}})'>图片显示</a>";
    html_head+="</h4><h4>舌照特征:"+ '{{tongue_vector}}'+"</h4>";
    $('#head').html(html_head);

    // //将数据显示出来--动态生成表格
    // var text_usr_dict = jsjx();
    // console.log(text_usr_dict);
    // var table="<table border=1><th rowspan=\"2\">序号</th>";
    //     table+=" <th rowspan=\"2\">患者信息：[年龄] [体重] [身高]</th>";
    //     table+="<th rowspan=\"2\">患者信息相似度1</th>";
    //     table+="<th rowspan=\"2\" width=500>自述</th>";
    //     table+="<th rowspan=\"2\">自述相似度2</th>";
    //     table+="<th colspan=\"3\">问诊单</th>";
    //     table+="<th rowspan=\"2\">问诊单相似度3</th>";
    //     table+="<th rowspan=\"2\">舌照</th>";
    //     table+="<th rowspan=\"2\">舌照特征</th>";
    //     table+="<th rowspan=\"2\">舌照相似h度4</th>";
    // table+="<tr><th>问题</th><th>相似患者答案</th><th>原始患者答案</th></tr>";
   //将数据显示出来--动态生成表格--相似患者
    // var text_usr_dict = jsjx();//获取相似患者数据
    var table="<table border=1><th rowspan=\"2\">序号</th>";
        table+=" <th rowspan=\"2\">患者信息：[年龄] [体重] [身高]</th>";
        table+="<th rowspan=\"2\"><button onclick='sortfunction(this.innerHTML)'>患者信息相似度1</button></th>";
        table+="<th rowspan=\"2\" width=500>自述</th>";
        table+="<th rowspan=\"2\"><button onclick='sortfunction(this.innerHTML)'>自述相似度2</button></th>";
        table+="<th colspan=\"3\">问诊单</th>";
        table+="<th rowspan=\"2\"><button onclick='sortfunction(this.innerHTML)'>问诊单相似度3</button></th>";
        table+="<th rowspan=\"2\">舌照</th>";
        table+="<th rowspan=\"2\">舌照特征</th>";
        table+="<th rowspan=\"2\"><button onclick='sortfunction(this.innerHTML)'>舌照相似h度4</button></th>";
        table+="<tr><th>问题</th><th>相似患者答案</th><th>原始患者答案</th></tr>";

    //循环生成表格的每一行
    var inquiry = '{{inquiry}}';
    var text_usr_dict = {{text_usr_dict|safe}};
    for(var j=0;j<indexList.length;j++){
        for(var i=0;i<text_usr_dict.length;i++){
            if(Number(text_usr_dict[i]['index'])===indexList[j]){
                //对问诊单部分的数据进行处理--方便左右两边显示
                //原始患者答案
                var originalAnswer = "";
                var inquiryDict = inquirySheet(inquiry);
                for(var key3 in inquiryDict){
                    originalAnswer += inquiryDict[key3].replace(/@@/g,'') + '\n';
                }
                //问题
                var inqueryDictQuestion = inquirySheet(text_usr_dict[i]['inquiry_sheet']);
                var keys = "";
                for(var key in inqueryDictQuestion){
                    keys += key + '\n';
                }
                //相似患者答案
                var similaryAnswer = "";
                for(var key2 in inqueryDictQuestion){
                    similaryAnswer += inqueryDictQuestion[key2] + '\n';
                }
                //将原始数据与现有数据进行对比，将相同的答案用红色标出
                var similaryAnswer2 = similaryAnswer.split('\n');
                var originalAnswer2 = originalAnswer.split('\n');
                for(m=0;m<similaryAnswer2.length;m++){
                    if(similaryAnswer2[m]===originalAnswer2[m]){
                        similaryAnswer2[m] = "<font color='red'>" + similaryAnswer2[m] +'</font>';
                        originalAnswer2[m] = "<font color='red'>" + originalAnswer2[m] +'</font>';
                    }
                }
                //换行显示
                similaryAnswer = similaryAnswer2.join('\n');
                originalAnswer = originalAnswer2.join('\n');
                similaryAnswer = similaryAnswer.replace(/\n/g,'<br>');
                originalAnswer = originalAnswer.replace(/\n/g,'<br>');
                keys = keys.replace(/\n/g,'<br>');
                //表格的每一行
                table+="<tr><td>"+text_usr_dict[i].index+"</td>";
                table += "<td>"+text_usr_dict[i]['patient_information']+"</td>";
                table+= "<td>"+text_usr_dict[i]['score_patient_information']+"</td>";
                table+= "<td>"+text_usr_dict[i]['condition_report']+"</td>";
                table+= "<td>"+text_usr_dict[i]['score_condition_report']+"</td>";
                table+= "<td  class='tableShow'>"+keys+"</td>";  //问题
                table+= "<td class='tableShow'>"+similaryAnswer+"</td>";  //相似病人答案
                table+= "<td class='tableShow'>"+originalAnswer+"</td>";  //原始病人答案
                table+= "<td>"+text_usr_dict[i]['score_inquiry_sheet']+"</td>";
                table+= "<td><a href='' onclick='fun(this.innerHTML)' '>图片文件"+i+"</a></td>";  //设置超链接，可以点击查看图片
                table+= "<td>"+text_usr_dict[i]['tongue_vector']+"</td>";
                table+= "<td>"+text_usr_dict[i]['score_tongue_vector']+"</td>" + "</tr>";
            }
        }
    }
    table += "</table>";
    console.log(table);
    $('#container').html(table);

</script>
</body>
</html>